import axios from 'axios'

const http = axios.create({
  baseURL: '/local',
  timeout: 3000,
  headers: {
    'Authorization': localStorage.getItem("cookie") || '',
    'tenant_id': JSON.parse(localStorage.getItem("userInfo") || "{}")?.tenant_id,
    'employee_id': JSON.parse(localStorage.getItem("userInfo") || "{}")?.employee_id
  }
})

http.interceptors.request.use(config => {
  return config
}) 
http.interceptors.response.use(res => {
  if(res.data.code === "000000") {
    window.location.href = window.location.origin + "/#/login"
  }
  return res.data
})

export default http
 